import { FormCreateItem } from '@/types/form-create';
import { PaginationProps } from 'naive-ui';
import { VxeGridPropTypes, VxeGridProps } from 'vxe-table';

import { QTableSearchProps } from '../q-table-search/type';

export type SearchData = {
	[key: string]: any;
} & PageParams;

export type PaginationParams = {
	page: number;
	pageSize: number;
};

export type PageTableColumn = VxeGridPropTypes.Column & {
	searchFormItem?: Partial<FormCreateItem>;
	hiddenInTable?: boolean;
};

export interface PageTableProps {
	searchConfig?: QTableSearchProps;
	paginationConfig?: Pick<PaginationProps, 'defaultPageSize' | 'pageSizes'>;
	showPager?: boolean;
	request?: (data: SearchData) => Promise<{
		data: any[];
		total?: number;
	}>;
	columns?: PageTableColumn[];
	operations?: OperationBtn<any>[];
}

export type OperationBtn<T> = {
	label: string;
	type?: 'error' | 'warning' | 'info';
	key: string;
	show?: boolean | ((row: T) => boolean);
};
